package com.dp.struct.proxy;

import java.lang.reflect.Proxy;

/**
 * This is to describe Proxy design pattern
 * 
 * This pattern provides a surrogate or placeholder for another object to
 * control access to it. Proxy means "in place of" the real object. There can be
 * ways for a proxy pattern. RemoteProxy [RMI], VirtualProxy [Hibernate],
 * Protection Proxy [Secure servers]
 * 
 * @author Sunaina.Sharma
 * 
 */
public class ProxyExample {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Animal realSubject = new Lion();
		Animal proxy = (Animal) Proxy.newProxyInstance(realSubject.getClass()
				.getClassLoader(), realSubject.getClass().getInterfaces(),
				new AnimalInvocationHandler(realSubject));
		proxy.getSound();
	}
}
